{extends file='layout/front.html'}

{block name='headApend'}
<link href="{$config_site_url}style/weibo.css" rel="stylesheet" type="text/css">
<link href="{$config_site_url}style/fixed.css" rel="stylesheet" type="text/css">
{/block}

{block name='main'}
<script type="text/javascript" charset="utf-8">
$('.menu1').attr('class', 'menu1_cur');
</script>
<script type="text/javascript" charset="utf-8" src="{$config_site_url}js/weibo.js"></script>
<div class="main_fixed">
<div class="main_t">
	<ul class="main_tab">
		<li><a href="#" class="current"><span>微博首页</span></a></li>
		<li><a href="#"><span>我的微博</span></a></li>
		<li><a href="#"><span>@我的</span></a></li>
		<li><a href="#"><span>我的评论</span></a></li>
		<li><a href="#"><span>我的粉丝</span></a></li>
		<li><a href="#"><span>我的关注</span></a></li>
	</ul>
</div>
<div class="main_t2">
	<ul class="main_min_tab tab_1">
		<li><a href="#" class="current"><span>全部</span></a></li>
		<li><a href="#"><span>原创</span></a></li>
		<li><a href="#"><span>图片</span></a></li>
		<li><a href="#"><span>视频</span></a></li>
		<li><a href="#"><span>音乐</span></a></li>
	</ul>
	<ul class="main_min_tab tab_2" style="display:none">
		<li><a href="#" class="current" onclick="return false;"><span>全部</span></a></li>
	</ul>

	<script type="text/javascript" charset="utf-8">
	index_pos = true;
	 $('.tab_1 a').click(function(){
	   if (timeline_lock) {
       return false;
     }
	   $('#weibo_bag').empty();
	   feature = $(this).index('.tab_1 a');
	   
	   load_timeline(0, true);
	   $('.tab_1 a').removeClass('current');
	   $(this).addClass('current');

	   return false;
	 });

	 $('.header,.header_user').wrapAll('<div class="header_fixed" />');
	 
	 $('.main_tab a').click(function(){
	   var index = $(this).index('.main_tab a');
	   $('#weibo_bag').empty();
	   
	   if (index == 0) {
	     friends = 0;
	     followers = 0;
	     comments_to_me = 0;
	     $('.tab_2').hide();
	     $('.tab_1').show();
	     mention = 0;
	     user_id = 0;
	   } else if (index == 1) {
	     friends = 0;
	     followers = 0;
	     comments_to_me = 0;
	     $('.tab_2').hide();
	     $('.tab_1').show();
	     mention = 0;
	     user_id = {$weibo_info.id};
	   } else if (index == 2) {
	     friends = 0;
	     followers = 0;
	     comments_to_me = 0;
	     $('.tab_2').show();
	     $('.tab_1').hide();
	     mention = 1;
	     user_id = 0;
	   } else if (index == 3) {
	     friends = 0;
	     followers = 0;
	     comments_to_me = 1;
	     $('.tab_2').show();
	     $('.tab_1').hide();
	     mention = 0;
	     user_id = 0;
	   } else if (index == 4) {
	     friends = 0;
	     followers = 1;
	     comments_to_me = 0;
	     $('.tab_2').show();
	     $('.tab_1').hide();
	     mention = 0;
	     user_id = {$weibo_info.id};
	   } else if (index == 5) {
	     friends = 1;
	     followers = 0;
	     $('.tab_2').show();
	     $('.tab_1').hide();
	     mention = 0;
	     user_id = {$weibo_info.id};
	   }

     load_timeline(0, true);
	   $('.main_tab a').removeClass('current');
	   $(this).addClass('current');

	   return false;
	 });
	</script>
</div>
</div>
<div class="main_c">
<!--weibo start-->
<div class="weibo_blk">
<div node-type="feed_list" pagenum="1" class="feed_lists W_linka W_texta" id="weibo_bag">
  

</div>
</div>
<script type="text/javascript" charset="utf-8">
$(window).scroll(function(){

  if ($(this).height()+$(this).scrollTop() >= $(document).height()-2) {
    var list = $('dl[action-type=feed_list_item]');
    var pos = $('dl[action-type=feed_list_item]').length - 1;
    var max_id = parseInt($('dl[action-type=feed_list_item]:eq('+pos+')').attr('mid'));
    if (max_id) {
        load_timeline(max_id, false);
    }
  }
  // distanceScrollCount = $(this)[0].scrollHeight;
  // distanceScroll = $(this)[0].scrollTop;
  // if(distanceScroll + $(this).height() >= distanceScrollCount) {
  //   alert('1');
    //  if (timeline_lock) {
    //   return false;
    // }
    // var list = $('dl[action-type=feed_list_item]');
    // var pos = $('dl[action-type=feed_list_item]').length - 1;
    // var max_id = parseInt($('dl[action-type=feed_list_item]:eq('+pos+')').attr('mid'));
    // load_timeline(max_id-1);
  //}

});

$('.main_tab a:eq({$smarty.get.t|default:0})').click();

cklock = false;
setInterval(function(){
  
if (cklock) {
  return false;
}
cklock = true;

if ($('.main_tab a:eq(0)').hasClass('current')) {
  var id = parseInt($('dl[action-type=feed_list_item]:eq(0)').attr('mid'));
  if (id > 100) {
    var add = 'feature='+feature+'&since_id='+id;
    
    $.get(SITE_URL+'/ajax/timeline.html?'+add, function(html){
      cklock = false;
      if (html == '') {
        return;
      }

      $('a[action-type=feed_list_newBar]').remove();
      $('#weibo_bag').prepend('<a href="" class="notes" action-type="feed_list_newBar">有新微博，点击查看</a>');
      $('a[action-type=feed_list_newBar]').click(function(){
        $(this).remove();
        $('#weibo_bag').prepend(html);
        return false;
      });
    });

  }
}

}, 60000);

</script>
<!--weibo end--> 
</div>
{/block}